<?php

namespace app\common\model;

use app\company\model\CompanyWarehouseArea;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;

class CompanyWarehouse extends BaseModel
{
    public function company(): BelongsTo
    {
        return $this->belongsTo(Company::class, 'company_id','id');
    }

    public function area(): HasMany
    {
        return $this->hasMany(CompanyWarehouseArea::class, 'warehouse_id', 'id');
    }

    public function local($companyId)
    {
        return self::where('company_id',$companyId)->find();
    }

    public function salesman(): BelongsTo
    {
        return $this->belongsTo(Salesman::class, 'salesman_id','id');
    }
}